<template>
    <div class="acceptance-registration-pages">
        <commpVxeTable
         :config="dataTableConfig" 
         :columns="columnsVxe" 
         :formItem="formItem"
         @checkboxChange="checkboxChange"
         ref="acceptanceRegistrationRef"
         >
            <!-- <template v-slot:externalOperations="{data}"  >
                <vxe-form-item>
                    <template>
                        <a-button class="blue-btn" type="primary" @click="approvalFormClick()">批量生成审批表</a-button>
                    </template>
                </vxe-form-item>
            </template> -->
            <template v-slot:operation_btn="{row}" data-desc="自定操作栏">
                <a-form layout="inline" class="search-form" >
                    <a-form-item >
                        <a-button class="blue-btn" type="primary" @click="reviseClick(row)" icon="edit">办理</a-button>
                    </a-form-item>
                    <!-- <a-form-item >
                        <a-button class="blue-btn" type="primary" @click="approvalFormClick(row)">生成审批表</a-button>
                    </a-form-item> -->
                    
                </a-form>
            </template>
        </commpVxeTable>

        <increase ref="refModel" :addEditParameter="addEditParameter" :viewFlag="true" @successReturn="successReturn" @reviseClick="reviseClick"/>
        <approvalForm ref="approvalFormRef"/>
    </div>
</template>
<script>
import {typeInput, typeNumber, typeSelect, typeCheckbox, typeRadio} from '@/components/compSearchCriteria/ContractType'
import assessCheckApi from './service/api.js'
import { deleteZltxwjFlow, ocalityPostAction, queryJobByJobId } from './service/index'
import commpVxeTable from '@/components/commp-vxe-table/commp-vxe-table.vue'
import increase from './increase.vue'
import moment from 'moment'
import approvalForm from './approvalForm.vue'
import blobType from '@/common/blobType'
  export default {
    components:{
        commpVxeTable,
        increase,
        approvalForm
    },
    
    data(){
        return{
            addEditParameter:{},
            formItem:[
                {
                    label: '文件名称',
                    model: 'fwjmc',
                },{
                    label: '分类',
                    model: 'ftype',
                },{
                    label: '类型',
                    model: 'fxglx',
                },{
                    label: '申请科室',
                    model: 'fsqks',
                }

            ],
            columnsVxe:[
                { type: 'checkbox', width: 60 ,fixed: 'left',},
                {
                    title: '申请人', //列头显示文字
                    field: 'fsqr',
                    fixed: 'left',
                },{
                    title: '申请科室', //列头显示文字
                    field: 'fsqks',
                },{
                    title: '文件名称',
                    field: 'fwjmc',
                },{
                    title: '分类',
                    field: 'ftype',
                },
                {
                    title: '类型',
                    field: 'fxglx',
                },{
                    title: '申请日期',
                    field: 'fsqrq',
                },{
                    title: '发送人',
                    field: 'ffsrmc',
                },{
                    title: '发送时间',
                    field: 'ffssj',
                },{
                    title: '操作',
                    field: 'jobid',
                    slots: {
                    // 使用插槽模板渲染
                    default: 'operation_btn',
                  },
                    fixed: 'right',
                    width:200,
                }],
            dataTableConfig:{
                api: assessCheckApi.zltxwjFlowJobPage,
                rowId: 'jobid',
                paramet:{
                    fhjmc:'管理者代表',
                    fblzt:'待办'
                }
            },
            specifyDateVal:'',
            isSpecifyDate:false,
            numFigure:1,
            numFigureVisible:false,
            currentReplicationId:'',
            selectedRowKeysArr:[],
        }
    },
    
    methods:{
        async dictionaryQuery(val){
            let dataObj = []
            await ocalityPostAction({dictName:val}).then(res=>{
                //console.log('字典的res',res)
                if(res.code == 200){
                    if(res.result.length){
                        dataObj = res.result
                    }
                    
                }
            })
            return dataObj
        },
        checkboxChange(val){//获取当前选择的行
            //console.log('当前选择表格',val)
            this.selectedRowKeysArr = []
            val.forEach(item => {
                this.selectedRowKeysArr.push(item.zltxwjid)
            });
            //console.log(this.selectedRowKeysArr)
        },
        approvalFormClick(val){
            if(val){
                this.$refs.approvalFormRef.getData(val.zltxwjid)
                this.$refs.approvalFormRef.visibleShow = true
            }else{
                if(this.selectedRowKeysArr.length){
                    this.$refs.approvalFormRef.getData(this.selectedRowKeysArr.join(','))
                    this.$refs.approvalFormRef.visibleShow = true
                }else{
                    this.$message.warning('请选择项')
                }
            }
        },
        successReturn(){
            this.$refs.acceptanceRegistrationRef.searchEvent()
        },

        handleOk(val,id){
            if(val && !id){
                this.$refs.acceptanceRegistrationRef.resetEvent()
            }else if(val && id){
                this.requestParams = {
                    ...this.requestParams,
                    renovate:true,
                }
            }
            
        },
        //编辑
        reviseClick(val){
            queryJobByJobId({jobid: val.jobid}).then(res=>{
                if(res.code == 200){
                    let data = res.result.zltxwj
                    this.addEditParameter = {
                        id:val.zltxwjid,
                        viewbutton:true,
                        jobid: res.result.job.id,
                        fblzt: res.result.job.fblzt,
                        fthyj: res.result.job.fthyj,
                        fhjmc: res.result.job.fhjmc,
                        zltxwjid: data.id,
                        fsqrq: data.fsqrq?moment(data.fsqrq).format('YYYY-MM-DD'):'',
                        fssrq: data.fssrq?moment(data.fssrq).format('YYYY-MM-DD'):'',
                        fscrq: data.fscrq?moment(data.fscrq).format('YYYY-MM-DD'):'',
                        fwjmc: data.fwjmc,
                        ftype: data.ftype,
                        forder: data.forder,
                        fwjbh: data.fwjbh, 
                        fxgcs: data.fxgcs,
                        fskbb: data.fskbb,
                        fwjlx: data.fwjlx,
                        fwjlj: data.fwjlj,
                        fzt: data.fzt,
                        fsqr: data.fsqr,
                        fsqks: data.fsqks,
                        fxglx: data.fxglx ? data.fxglx : '修订',
                        fxdly: data.fxdly,
                        fqcsm: data.fqcsm,

                        // nextNodeDbrList: res.result.nextNodeDbrList,
                        nextNode: res.result.nextNode,
                        ffsr: data.ffsr,
                        ffssj: data.ffssj,
                        fblr: data.fblr,
                        dbrid: [],
                        opinion: '',//办理意见
                        smgflag: '否',//是否发送短信
                    }
                    this.$refs.refModel.visibleShow = true
                    this.$refs.refModel.spinning = true
                    this.$aSpinningKey = true
                }else{
                    this.$message.warning(res.message)
                }
            })
            
            
        },
        
        AddHandleOk(){
            this.$refs.acceptanceRegistrationRef.resetEvent()
        },
    },

  }
</script>
<style lang="less">
.acceptance-registration-pages{
    .select-date-box{
        display: flex;
        flex-direction: column;
        span{
            color: #f5222d;
            font-size: 14px;
        }
    }
    .modal-btn-box{
        .ant-form-item-control{
            width: 175px !important;
        }
    }
    
}
</style>
<style scoped >
.observer-lbrary-pages{
    background: #fff;
}
.btn-box{
    display: flex;
    justify-content: flex-end;
}
.blue-btn{
    border: 1px solid #5ca3e5 !important;
    background-color: #5ca3e5 !important;
    color: #fff !important;
}
.red-btn{
    border: 1px solid #ed5565 !important;
    background-color: #ed5565 !important;
}




</style>